package com.guoxianwei.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.guoxianwei.scm.domain.Menu;

public class TestGson {
	
	public static void main(String[] args) {
		
		Menu menu = new Menu();
		menu.setMenuid(1);
		menu.setMenuno("menu1");
		Menu menu2 = new Menu();
		menu2.setMenuid(2);
		menu2.setMenuno("menu2");
		List<Menu> menus = new ArrayList<Menu>();
		menus.add(menu);
		
		menus.add(menu2);
		List<Menu> submenus = new ArrayList<Menu>();

		Menu submenu = new Menu();
		submenu.setMenuid(22);
		submenu.setMenuno("submenu");
		submenus.add(submenu);
		menu2.setChildren(submenus);
		Map map = new HashMap();
		map.put("MENU", menus);
		String json = GSONUtils.toJson(menus, false);
		String ss = "{\"rules\":[{\"op\":\"like\",\"field\":\"lastName\",\"value\":\"test\",\"type\":\"string\"}]}";
		Map<String,List<Map<String,String>>> map2 = GSONUtils.fromJson(ss, new TypeToken<Map<String,List<Map<String,String>>>>(){});
		
		System.out.println(map2.get("rules"));
	}
}
